//
//  LabelPriorityTableViewCell.m
//  XMenSwift
//
//  Created by Jason on 2022/3/23.
//

#import "LabelPriorityTableViewCell.h"
#import <Masonry/Masonry.h>


@interface LabelPriorityTableViewCell()
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *timeLabel;
@property (strong, nonatomic) UILabel *contenLabel;

@property (strong, nonatomic) UILabel *nameLabel;
@property (strong, nonatomic) UILabel *phoneLabel;

@end

@implementation LabelPriorityTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self steupUi];
    }
    return self;
}

- (void)steupUi {
    
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:bgView];
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor grayColor];
    line.alpha = 0.4;
    [self.contentView addSubview:line];
   
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont systemFontOfSize:16.0];
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.text = @"优先级问题优优先级问题优优先级问题优";
    [bgView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.font = [UIFont systemFontOfSize:14.0];
    timeLabel.textColor = [UIColor grayColor];
    timeLabel.text = @"2020-08-09 14:45:40右边优先";
    [bgView addSubview:timeLabel];
    self.timeLabel = timeLabel;
    
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.font = [UIFont systemFontOfSize:16.0];
    nameLabel.textColor = [UIColor grayColor];
    nameLabel.text = @"左边优先设置最大值这是名称看看最大内容是多少";
    [bgView addSubview:nameLabel];
    self.nameLabel = nameLabel;
    
    UILabel *phoneLabel = [[UILabel alloc] init];
    phoneLabel.font = [UIFont systemFontOfSize:16.0];
    phoneLabel.textColor = [UIColor grayColor];
    phoneLabel.text = @"18027231173";
    [bgView addSubview:phoneLabel];
    self.phoneLabel = phoneLabel;
    
    UILabel *contenLabel = [[UILabel alloc] init];
    contenLabel.font = [UIFont systemFontOfSize:14.0];
    contenLabel.textColor = [UIColor blackColor];
    contenLabel.text = @"这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气这是内容啊 今天是个好天气";
    contenLabel.numberOfLines = 0;
    [bgView addSubview:contenLabel];
    self.contenLabel = contenLabel;
    
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(15);
        make.bottom.mas_equalTo(-15);
    }];
    
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
        make.bottom.mas_equalTo(0);
    }];
    
   
    [self.titleLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView);
        make.left.equalTo(bgView);
        make.height.mas_greaterThanOrEqualTo(20);
    }];
    
    [self.timeLabel setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView);
        make.left.equalTo(titleLabel.mas_right).offset(10);
        make.right.equalTo(bgView);
        make.height.equalTo(titleLabel);
        //优先也必须设置最大值 否则另一边会被挤没
        make.width.mas_lessThanOrEqualTo(250);
    }];
    
    [self.nameLabel setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(titleLabel.mas_bottom).offset(10);
        make.left.equalTo(titleLabel);
        make.height.mas_greaterThanOrEqualTo(20);
        //优先也必须设置最大值 否则另一边会被挤没
        make.width.mas_lessThanOrEqualTo(200);

    }];
    
    [self.phoneLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLabel);
        make.left.equalTo(nameLabel.mas_right).offset(10);
        make.right.equalTo(bgView);
        make.height.equalTo(nameLabel);

    }];
    
    
    [self.contenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLabel.mas_bottom).offset(10);
        make.left.equalTo(titleLabel);
        make.right.equalTo(bgView);
        make.bottom.equalTo(bgView);
    }];
}

@end
